class Solution:
    def findShortestSubArray(self, nums: List[int]) -> int:
        c = collections.Counter(nums)
        min_ans = inf
        tup_list = c.most_common()
        most_freq = tup_list[0][1]
        for j in range(len(tup_list)):
            k = tup_list[j][0]
            v = tup_list[j][1]
            if v == most_freq:
                index = [i for i,x in enumerate(nums) if x==k]
                ans = index[-1] - index[0]+1
                min_ans = min(ans, min_ans)
            else:
                break
        return min_ans

